package com.jd.event;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.DelayQueue;

public class ScheduedEventReposity implements EventReposity {
	public static final Map<String, DelayQueue<EventTarget>> queuesMap = new HashMap<String, DelayQueue<EventTarget>>();

	public void addEvent(String group, Event<?> event) {
		if (event.getEventTime() == null) {
			throw new EventException("event time must not null!");
		}
		DelayQueue<EventTarget> queue = this.getQueue(group);
		EventTarget target = new EventTarget(event);
		queue.add(target);

	}

	public void addQueue(String group, DelayQueue<EventTarget> queue) {
		queuesMap.put(group, queue);
	}

	private DelayQueue<EventTarget> getQueue(String group) {
		return queuesMap.get(group);
	}

}
